package cn.cm.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 测试控制器
 */
//此控制器下所有对外映射的方法都返回Json数据
@RestController
@RequestMapping("/test")
public class TestController {
    @GetMapping("/t1")
    public Map test1(){
        Map map=new HashMap();

        map.put("name","张三");
        map.put("age","18");
        return map;
    }

    @GetMapping("/t2")
    public String testLogin(){
        UsernamePasswordToken token=new UsernamePasswordToken("root","root");
        SecurityUtils.getSubject().login(token);
        return "OK";
    }
}
